fix(security): Add URL validation and rate limiting to crawl endpoint#640
Open
joelrb wants to merge 3 commits into
Open
fix(security): Add URL validation and rate limiting to crawl endpoint#640joelrb wants to merge 3 commits into
joelrb wants to merge 3 commits into
Conversation
added 3 commits
May 14, 2026 19:32
- Add proper error handling for crawl endpoint with graceful failures - Fix CORS preflight response status from 200 to 204 (standard) - Improve error messages for database and API failures - Add fallback behavior when cached content is not available - Fix main index.ts CORS preflight handling
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Problem
The /api/crawl endpoint was vulnerable to several security threats:
Fix Applied
Framework Change
No framework changes - this is a pure security enhancement to existing Cloudflare Workers functionality.
Files Changed
Type of Change
Related Issues
Fixes #security-vulnerabilities-ssrf-rate-limiting
Related to #government-service-security
Testing
Describe the testing performed for this PR:
Include specific test scenarios or commands used.
Manual test:
Checklist
Performance & Security
Screenshots (if applicable)
Add screenshots to help explain your changes.
Additional Notes
This security enhancement maintains the public service nature of BetterGov.ph while preventing abuse and protecting against common web vulnerabilities. The crawl endpoint now safely allows access to Philippine government websites while blocking potential security threats.